<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ props: {disabled: disableSubmit} }"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel">
    <!-- 主表单区域 -->
    <a-form :form="form" >
      <template v-for="(item,index) in dataResources" >
        <a-row style="margin-left: -160px">
          <a-form-item v-is-group label="所属公司" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <j-company-select-tag disabled="disabled" placeholder="请选择所属公司" v-bind:value="item.companyId"/>
          </a-form-item>

          <a-form-item label="变动记录" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-textarea rows="4" v-bind:value="item.balanceDetailed"></a-textarea>
          </a-form-item>
        </a-row>
      </template>
    </a-form>
  </j-modal>
</template>

<script>

  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import JUpload from '@/components/jeecg/JUpload'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  import { updateCustomerBalance } from '@/api/customer'
  import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
  import { getAction } from '@api/manage'


  export default {
    name: 'UpdateCustomerBalanceModal',
    components: {
      JDate,
      JUpload,
      JCompanySelectTag,
      JDictSelectTag
    },
    data () {
      return {
        url:{
          queryBalanceDetailed:"/zcgl/customerInfo/queryBalanceDetailed"
        },
        dataResources:[],
        form: this.$form.createForm(this),
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 3 }
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 20 }
        },
        width: 900,
        disableSubmit: false,
        confirmLoading: false,
        visible: false,
        title: '',
        model: {},
      }
    },
    methods: {
      show (record) {
        debugger
        this.confirmLoading = false
        this.title = '余额变动详情'
        this.form.resetFields()
        this.model = Object.assign({}, record)
        this.visible = true
        this.model.changesType = 1
        this.loading1 = true
        this.dataResources=[];
        getAction(this.url.queryBalanceDetailed, {customerId:record.id}).then((res) => {
          if (res.success) {
            if(res.result.length>0){
              this.dataResources=res.result;
            }else{
              this.dataResources.push({companyId:"", balanceDetailed:""});
            }
           console.log(this.dataResources);
          }
        }).finally(() => {
          this.loading1 = false
        })

      },
      handleOk () {
      },
      handleCancel () {
        this.close()
      },
      close () {
        this.$emit('close')
        this.visible = false
      }
    }
  }
</script>

<style scoped>
</style>